/*
* $Id: ConvertFunction.cpp 54 2010-03-09 20:16:01Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "../include.h"

time_t CConvertFunction::ConvertFromDate(const std::tstring& strDate){
	time_t nTime = 0;
	if(strDate.size() >= 10 && strDate[2] == '.' && strDate[5] == '.'){
		 tm Tm = {0};
		 Tm.tm_year = _ttoi(std::tstring(strDate.begin() + 6, strDate.begin() + 10).c_str()) - 1900;
		 Tm.tm_mon = _ttoi(std::tstring(strDate.begin() + 3, strDate.begin() + 5).c_str()) - 1;
		 Tm.tm_mday = _ttoi(std::tstring(strDate.begin(), strDate.begin() + 2).c_str());
		 nTime = mktime(&Tm);
	}
	return nTime;
}

std::tstring CConvertFunction::ConvertFromDate(time_t Time){
	TCHAR temp[11] = {0};
	tm Tm;
	localtime_s(&Tm, &Time);
	_tcsftime(temp, 11, _T("%d.%m.%Y"), &Tm);
	return temp;
}
std::tstring CConvertFunction::ConvertFromInt(int nInt){
	TCHAR temp[32] = {0};
	_itot_s(nInt, temp, 32, 10);
	return temp;
}